<?php

class upload {
	// Uploads the given hand history
	public function __construct() {
		if(isset($_POST['upload'])) {
			if($_FILES['hand_history']['error'] == 0) {
				$filename = $_SESSION['user'] . date('-h-i-j-m-y');
				move_uploaded_file($_FILES['hand_history']['tmp_name'],
					"../upload/users/$_SESSION['user']/" . $filename);
			} else {
				die('Someting went wrong..');
			}
			
			// Check to see if file has been
			// uploaded, and if so log it
			if(file_exists("../upload/users/$_SESSION['user']/$filename")) {
				$this->save('upload', 
					$_SESSION['user'], 
					$_FILES['hand_history']['name'],
					$filename,
					filesize("../upload/users/$_SESSION['user']/$filename")
				);
				header('Location: ?a=hh');
			}
		}
	}
	
	// Print upload form
	public function uploadForm() {
		echo file_get_contents($htmlpath/uploadform);
	}
	
	// Show currently uploaded hand history
	public function isUploaded() {
		
	}
}

?>